from typing import *


class Solution:
    def getGoodIndices(self, variables: List[List[int]], target: int) -> List[int]:
        ans = []

        def pow(a, b, m):
            if b == 0:
                return 1
            k = pow(a, b // 2, m) % m
            return k * k * (a if b & 1 == 1 else 1) % m

        for i, (a, b, c, m) in enumerate(variables):
            if pow(pow(a, b, 10), c, m) == target:
                ans.append(i)
        return ans

print(len("aea590ee9c74e9793d9e75db74c61cef"))
print(len("Iff8080810190fc29fc291d950190fd1ae4c70059"))
